<?php

class ManageDoAddCustomerAction extends LtAction
{
	public function __construct()
	{
		parent::__construct();
		$this->responseType = 'tpl';
		$this->layout = 'bylayout';
	}

	public function execute()
	{
		$postdata = $this->context->post('postdata');
		//var_dump($postdata);exit;

		if(isset($postdata['cname']) && !empty($postdata['cname']))
		{

			if(!isset($postdata['status']))
			{
				$postdata['status'] = 0;
			}
			$tmcustomer = new CustomerDao();
			$addre  = $tmcustomer->add($postdata);
			if($addre)
			{
				$noticeStr = "succ to do add ".$postdata['cname'];
			}
			else
			{
				$noticeStr = "fail to do add, db return false";
			}
		}
		else
		{
			$noticeStr = "fail to do add, no canme";
		}

		$redirectUrl = C('LtUrl')->generate('manage','Customer', array('noticestr'=>$noticeStr));
		header('Location: '.$redirectUrl);
	}
}
?>
